|
|
 |
|
|
|
|
Private Sub cmdConnect_Click()
Dim oRS As Recordset
Dim strSQL As String
strSQL = "SELECT "
strSQL = strSQL & "szLast_nm, "
strSQL = strSQL & "sFirst_nm "
strSQL = strSQL & "FROM tblEmployees "
Set oRS = New Recordset
oRS.Open strSQL, _ ConnectString(), _ adOpenForwardOnly, _
adLockReadOnly, _
adCmdText
lstNames.Clear
Do Until oRS.EOF
lstNames.AddItem oRS("szLast_nm") & _
", " & oRS("sFirst_nm")
oRS.MoveNext
Loop
oRS.Close
End Sub |
|
|
|
|
|
|
|
|
In this Open method, you pass in a string value as the second parameter instead of specifying a Connection object. When you do this, you tell the Recordset object to open a new connection when it generates this resultset. |
|
|
|
|
|
|
|
|
Error handling in ADO is very similar to error handling in Jet and RDO. The Connection object contains an Errors collection that contains one or many Error objects. If a data access error occurs, these Error objects are generated and placed in the connections Errors collection. The Error object contains several properties that give you a description of the error that has occurred. |
|
|
|
|
|